/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author Keith
 */
public class Note {

    private String id;
    private String text;
    private String xPos;
    private String yPos;
    private String color;
    private String height;
    private String width;
    private String time;
    private String audio;
    private String video;

    public Note() {
    }

    private Note(String id, String text, String xPos, String yPos, String color, String height, String width, String zIndex, String time, String audio, String video) {
        this.id = id;
        this.text = text;
        this.xPos = xPos;
        this.yPos = yPos;
        this.color = color;
        this.height = height;
        this.width = width;
        this.time = time;
        this.audio = audio;
        this.video = video;
    }

    public static Note noteFromNode(Node n) {
        Note note = new Note();
        NodeList nl = n.getChildNodes();
        note.setId(nl.item(0).getFirstChild().getTextContent());
        note.setxPos(nl.item(1).getFirstChild().getTextContent());
        note.setyPos(nl.item(2).getFirstChild().getTextContent());
        note.setHeight(nl.item(3).getFirstChild().getTextContent());
        note.setWidth(nl.item(4).getFirstChild().getTextContent());
        note.setColor(nl.item(5).getFirstChild().getTextContent());
        note.setTime(nl.item(6).getFirstChild().getTextContent());
        if(nl.item(7).getFirstChild() != null)
            note.setText(nl.item(7).getFirstChild().getTextContent());
        else
            note.setText("");
        //TODO
        //Audio Video
        
        for (int i = 0; i < nl.getLength(); i++) {
            System.out.println(nl.item(i).getNodeName());
        }
        return note;
    }

    public String getColor() {
        return color;
    }

    private void setColor(String color) {
        this.color = color;
    }

    public String getHeight() {
        return height;
    }

    private void setHeight(String height) {
        this.height = height;
    }

    public String getId() {
        return id;
    }

    private void setId(String id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    private void setText(String text) {
        this.text = text;
    }

    public String getTime() {
        return time;
    }

    private void setTime(String time) {
        this.time = time;
    }

    public String getWidth() {
        return width;
    }

    private void setWidth(String width) {
        this.width = width;
    }

    public String getxPos() {
        return xPos;
    }

    private void setxPos(String xPos) {
        this.xPos = xPos;
    }

    public String getyPos() {
        return yPos;
    }

    private void setyPos(String yPos) {
        this.yPos = yPos;
    }

    public String toXML() {
        return toString();
    }

    public String getAudio() {
        return audio;
    }

    private void setAudio(String audio) {
        this.audio = audio;
    }

    public String getVideo() {
        return video;
    }

    private void setVideo(String video) {
        this.video = video;
    }

    @Override
    public String toString() {
        String n = "<note>"
                + "<id>" + getId() + "</id>"
                + "<x_pos>" + getxPos() + "</x_pos>"
                + "<y_pos>" + getyPos() + "</y_pos>"
                + "<height>" + getHeight() + "</height>"
                + "<width>" + getWidth() + "</width>"
                + "<color>" + getColor() + "</color>"
                + "<time>" + getTime() + "</time>"
                + "<text>" + getText() + "</text>"
                //TODO
                //Audio Video
                + "</note>";
        return n;
        // TODO - Audio Video URLs
    }
}
